<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
</head>
<style>
    input:disabled {
        background: #e8e8e8;
    }
</style>
<body>
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <input type="hidden" name="id" value="{$find.id}">
    <input type="hidden" name="uid" value="{$find.uid}">
    <input type="hidden" name="latitude" value="{$find.latitude}">
    <input type="hidden" name="longitude" value="{$find.longitude}">
    <div class="layui-form-item">
        <label class="layui-form-label">提供礼品人</label>
        <div class="layui-input-inline">
            <input type="text" disabled value="{$find.name}" placeholder="提供礼品商家" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">礼品名称</label>
        <div class="layui-input-inline">
            <input type="text" name="lipin" value="{$find.lipin}" lay-verify="required" placeholder="请输入礼品名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">礼品封面</label>
        <div class="layui-input-inline">
            <input type="text" name="img" value="{$find.img}" lay-verify="required" placeholder="请上传礼品封面" autocomplete="off" class="layui-input">
        </div>
        <button style="float: left;" type="button" class="layui-btn" id="up">上传封面</button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">礼品数量</label>
        <div class="layui-input-inline">
            <input type="number" name="num" value="{$find.num}" lay-verify="required|number" placeholder="请输入礼品数量" autocomplete="off" class="layui-input">
        </div>
        <div style="line-height: 35px;color: #8e8e8e;">(每期礼品数量)</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">期数</label>
        <div class="layui-input-inline">
            <input type="number" name="stage" value="{$find.stage}" lay-verify="required|number" placeholder="请输入期数" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">每期间隔</label>
        <div class="layui-input-inline">
            <input type="number" name="ge" value="{$find.ge}" lay-verify="required|number" placeholder="请输入每期领取间隔天数" autocomplete="off" class="layui-input">
        </div>
        <div style="line-height: 35px;color: #8e8e8e;">(每期领取间隔天数)</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">每单佣金</label>
        <div class="layui-input-inline">
            <input type="number" name="gold" value="{$find.gold ? $find.gold : 0}" lay-verify="required|number" placeholder="请输入期数" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">领取方式</label>
        <div class="layui-input-inline">
            <select name="mode" lay-verify="required">
                <option value="">请选择领取方式</option>
                <option value="0" {eq name='find.mode' value='0'}selected{/eq}>到店免费领取</option>
                <option value="1" {eq name='find.mode' value='1'}selected{/eq}>到店消费领取</option>
                <option value="2" {eq name='find.mode' value='2'}selected{/eq}>线上充值领取</option>
                <option value="3" {eq name='find.mode' value='3'}selected{/eq}>线上免费领取</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">消费金额</label>
        <div class="layui-input-inline">
            <input type="number" name="money" value="0" lay-verify="required|number" placeholder="需要消费金额" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">礼品价值</label>
        <div class="layui-input-inline">
            <input type="number" name="price" value="{$find.price}" lay-verify="required|number" placeholder="礼品价值" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">礼品领取地址</label>
        <div class="layui-input-inline" style="width: 400px;">
            <textarea name="address" lay-verify="required" placeholder="请输入商家地址" class="layui-textarea">{$find.address}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="审核">
    </div>
</div>
<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'upload', 'form'], function(){
        var $ = layui.$,
                form = layui.form,
                upload = layui.upload;

        //普通图片上传
        upload.render({
            elem: '#up'
            ,url: "{:url('User/upload')}"
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                //上传成功
                layer.msg('上传成功');
                $("input[name=img]").val(res.img);
            }
        });

        //监听提交
        form.on('submit(layuiadmin-app-form-submit)', function(data){
            var field = data.field; //获取提交的字段
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            var load = layer.load();
            $.ajax({
                type: "POST",
                url: "{:url('Gift/examine_shenhe')}",
                data: {field:field},
                dataType: "json",
                success: function(e){
                    layer.close(load);
                    if (e.info == 1){
                        layer.msg('审核成功', {offset: ['30%', '40%']});
                        setTimeout(function () {
                            parent.layui.table.reload('demo'); //重载表格
                            parent.layer.close(index); //再执行关闭
                        }, 500)
                    }else{
                        layer.msg(e.msg, {offset: ['30%', '40%']});
                    }
                }
            });
        });
    })
</script>
</body>
</html>